#include "stdafx.h"
#include "GxTickEventSink.h"
#include "SymbolManager.h"
#include "p2_i.c"

/////////////////////////////////////////////////////////////////////////////
// GxTickEventSink

IMPLEMENT_DYNCREATE(GxTickEventSink, CCmdTarget)

GxTickEventSink::GxTickEventSink()
{
	EnableAutomation();
}

GxTickEventSink::~GxTickEventSink()
{
}


void GxTickEventSink::OnFinalRelease()
{
	// When the last reference for an automation object is released
	// OnFinalRelease is called.  The base class will automatically
	// deletes the object.  Add additional cleanup required for your
	// object before calling the base class.
	m_Cookie = 0;
	CCmdTarget::OnFinalRelease();
}


BEGIN_MESSAGE_MAP(GxTickEventSink, CCmdTarget)
	//{{AFX_MSG_MAP(GxTickEventSink)
	// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(GxTickEventSink, CCmdTarget)
	//{{AFX_DISPATCH_MAP(GxTickEventSink)
	DISP_FUNCTION(GxTickEventSink, "OnNewTick", OnNewTick, VT_EMPTY, VTS_DISPATCH VTS_DISPATCH)
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()

// Note: we add support for IID_IGxTickEventSink to support typesafe binding
//  from VBA.  This IID must match the GUID that is attached to the 
//  dispinterface in the .ODL file.

// {C0A0DEB9-2412-41C1-B46D-A9B8FBC971DB}
//static const IID IID_IGxTickEventSink =
//{ 0xc0a0deb9, 0x2412, 0x41c1, { 0xb4, 0x6d, 0xa9, 0xb8, 0xfb, 0xc9, 0x71, 0xdb } };

BEGIN_INTERFACE_MAP(GxTickEventSink, CCmdTarget)
	INTERFACE_PART(GxTickEventSink, DIID_IGxLastTickEvents, Dispatch)
END_INTERFACE_MAP()

/////////////////////////////////////////////////////////////////////////////
// GxTickEventSink message handlers

void GxTickEventSink::OnNewTick(LPDISPATCH a_GxSymbol, LPDISPATCH a_GxLastTick)
{
	// TODO: Add your dispatch handler code here
	if (m_SymbolMgr)
	{
		m_SymbolMgr->OnTickChanged();
	}
}
